<template>
	<view class="store_details" :style="{ 'padding-bottom': flag == true ? '170rpx' : '102rpx' }">
		<view class="tab_nav">
			<nav-bar
				nav_btn="back"
				:title="title"
				:color="color"
				:placeholder="placeholder"
				:list="list"
				:auto_img="image"
				:imgType="imgType"
				:showGoodsNav="showGoodsNav"
				:state="state"
			></nav-bar>
		</view>
		<view class="nav_back"></view>
		<view class="dingdan_wanc_box flex" v-if="goodsDetail.state == 6">
			<view class="wc_left_image">
				<image class="w100 h100" src="../static/ddwc.png"></image>
			</view>
			<view class="wc_right_txt f500 family">订单已完成</view>
		</view>
		<view class="dingdan_wanc_box flex" v-if="goodsDetail.state == 2">
			<view class="wc_left_image">
				<image class="w100 h100" src="@/static/time.png"></image>
			</view>
			<view class="wc_right_txt f500 family">等待商家发货</view>
		</view>
		<view class="payment_box flex" v-if="goodsData.state == 1 && goodsData.paymenttime == null">
			<view class="mar-auto flex">
				<view class="payment_txt s28 f500 family">需付款：</view>
				<view class="payment_money s28 familytow fblod">￥{{ goodsDetail.pay.order_price }}</view>
			</view>
			<view class="mar-auto flex">
				<view class="surplus_txt s28 family f500">剩余：</view>
				<view class="payment_money s28 familytow fblod">
					<djs :index="index" :times="goodsData.endtime" @del="delOrder"></djs>
				</view>
			</view>
		</view>
		<view class="payment_box flex" v-if="goodsDetail.state == 3">
			<view class="mar-auto flex">
				<view v-if="goodsDetail.state == '3' && goodsDetail.express_no !== ''" class="payment_money s28 familytow fblod">
					{{ goodsDetail.send_type == 0 ? '商品已发货' : goodsDetail.send_type == 1 ? '商家配送中' : goodsDetail.logistics.status }}
				</view>
				<view v-else class="payment_money s28 familytow fblod">
					{{ goodsDetail.logistics.status }}
				</view>
			</view>
		</view>
		<view class="payment_box flex" v-if="goodsDetail.state == 7">
			<view class="mar-auto flex">
				<view class="payment_money s28 familytow fblod">您已取消该订单!</view>
			</view>
		</view>
		<view class="content">
			<view class="scroll-Y">
				<view class="goods_box">
					<view class="sotre_name_box flex">
						<view class="sotre_name s28 f500 family">
							{{ goodsDetail.shop.shopname }}
						</view>
						<view class="right_jian">
							<image class="w100 h100" src="../static/right_jian_back.png"></image>
						</view>
					</view>
					<view class="goods_details" v-for="(item, index) in goodsDetail.goods" :key="index">
						<view class="flex">
							<view class="goods_image">
								<image class="w100 h100" :src="goodsDetail.sku[0].thumbnail ? goodsDetail.sku[0].thumbnail : item.image_src"></image>
							</view>
							<view class="goods_name_status">
								<view class="goods_name s26 family f500">
									{{ spceType(item.title, item.difference, goodsDetail.sku[0].spec_type) }}
								</view>
								<view class="yixuan_bod s24 familythree" v-if="item.type == 'goods'">【已选】{{ item.difference }}</view>
								<view class="money_num_box flex flexjus" :style="{ 'margin-top': item.type == 'package' ? '74rpx' : '34rpx' }">
									<view class="flex">
										<view class="money_name s40 family f500">￥{{ item.price }}</view>
										<view class="huax_money s24 f400">￥{{ item.market_price }}</view>
									</view>
									<view class="goods_num s28 familytow fblod">X{{ item.number }}</view>
								</view>
							</view>
						</view>
						<view class="gift_box" v-if="item.type == 'goods'">
							<view class="gift_list flex flexjus" v-for="(items, indexs) in item.gift" :key="indexs">
								<view class="gift_left_txt s22 familythree f400">【赠品】{{ items.name }}</view>
								<view class="gift_right_num s22 familythree f400">X{{ items.number }}</view>
							</view>
						</view>
						<view class="gift_box" v-if="item.type == 'package'">
							<view class="gift_list flex flexjus" v-for="(items, indexs) in item.gift" :key="indexs">
								<view class="gift_left_txt s22 familythree f400">【赠品】{{ items.attr_value }}</view>
								<view class="gift_right_num s22 familythree f400">X{{ items.number }}</view>
							</view>
						</view>
					</view>
				</view>
				<view v-if="goodsDetail.state !== 7" class="place_order_box">
					<view class="place_list flex">
						<view class="place_txt s24 familythree f400">推荐人：</view>
						<view class="place_dy_txt s24 f500 family">
							<view v-if="goodsDetail.referr.name" class="bold" style="color: #000000">
								{{ goodsDetail.referr.name }}（{{
									goodsDetail.referr.iden == 1
										? '注册会员'
										: goodsDetail.referr.iden == 2
										? '返利会员'
										: goodsDetail.referr.iden == 3
										? '商家职员'
										: goodsDetail.referr.iden == 4
										? '城市合伙人'
										: goodsDetail.referr.iden == 5
										? '店铺合伙人'
										: ''
								}}）
							</view>
							<view v-else>无</view>
						</view>
					</view>
					<view class="place_list flex">
						<view class="place_txt s24 familythree f400">订单编号：</view>
						<view class="place_dy_txt s24 f500 family">
							{{ goodsDetail.order_no }}
						</view>
					</view>

					<view class="place_list flex">
						<view class="place_txt s24 familythree f400">下单时间：</view>
						<view class="place_dy_txt s24 f500 family">
							{{ goodsDetail.createtime_text }}
						</view>
					</view>

					<view class="place_list flex">
						<view class="place_txt s24 familythree f400">订单人：</view>
						<view class="place_dy_txt s24 f500 family">
							{{ goodsDetail.username || '' }}
						</view>
					</view>
					<view class="place_list flex">
						<view class="place_txt s24 familythree f400">订单号码：</view>
						<view class="place_dy_txt s24 f500 family">
							{{ (goodsDetail.mobile && goodsDetail.mobile.replace(/(\d{3})(\d{4})(\d{4})/, '$1 $2 $3')) || '' }}
							<text v-if="goodsDetail.mobile && state1 != 0" class="phone_txt s24 family f500" style="margin-left: 22upx" @click="getPhone">拨号</text>
						</view>
					</view>
					<view class="place_list flex" v-if="goodsDetail.send_type != 2">
						<view class="place_txt s24 familythree f400">收货地址：</view>
						<view class="place_dy_txt s24 f500 family">
							{{ goodsDetail.address.address + goodsDetail.address.address_name }}
						</view>
					</view>
					<view class="place_list flex">
						<view class="place_txt s24 familythree f400">支付方式：</view>
						<view class="place_dy_txt s24 f500 family">
							{{
								!goodsDetail.paymenttime
									? '待支付'
									: goodsDetail.pay.pay_type == 0
									? '充值支付'
									: goodsDetail.pay.pay_type == 1
									? '微信支付'
									: goodsDetail.pay.pay_type == 2
									? '支付宝支付'
									: goodsDetail.pay.pay_type == 3
									? '混合支付'
									: ''
							}}
							{{ goodsDetail.paymenttime ? (goodsDetail.pay.is_prepay == 1 ? '（定金支付）' : '（全款支付）') : '' }}
						</view>
					</view>
					<block v-if="goodsDetail.goods[0].type != 'package'">
						<view class="place_list flex">
							<view class="place_txt s24 familythree f400">配送方式：</view>
							<view class="place_dy_txt s24 f500 family">
								{{ goodsDetail.send_type == 0 ? '快递' : goodsDetail.send_type == 1 ? '商家配送' : '自提' }}
							</view>
						</view>
						<view class="place_list flex">
							<view class="place_txt s24 familythree f400">运费：</view>
							<view class="place_dy_txt s24 f500 family">￥{{ goodsDetail.pay.freight_price }}</view>
						</view>
					</block>
					<view v-if="goodsDetail.express_name" class="place_list flex">
						<view class="place_txt s24 familythree f400">物流公司：</view>
						<view class="place_dy_txt s24 f500 family">
							{{ goodsDetail.express_name || '' }}
						</view>
					</view>
					<view v-if="goodsDetail.express_no" class="place_list flex">
						<view class="place_txt s24 familythree f400">快递单号：</view>
						<view class="place_dy_txt s24 f500 family">
							{{ goodsDetail.express_no || '' }}
						</view>
					</view>
					<view class="place_list flex" v-if="!goodsDetail.pay.coupon_id">
						<view class="place_txt s24 familythree f400">会员优惠：</view>
						<view class="place_dy_txt s24 f500 family">￥{{ goodsDetail.pay.discount_price }}</view>
					</view>
					<view class="place_list flex" v-if="goodsDetail.pay.coupon_id">
						<view class="place_txt s24 familythree f400">优惠券：</view>
						<view class="place_dy_txt s24 f500 family">￥{{ goodsDetail.pay.discount_price }}</view>
					</view>
					<view class="place_list flex">
						<view class="place_txt s24 familythree f400">充值支付：</view>
						<view class="place_dy_txt s24 f500 family">￥{{ goodsDetail.pay.balance_price }}</view>
					</view>
					<view class="place_list flex">
						<view class="place_txt s24 familythree f400">微信支付：</view>
						<view class="place_dy_txt s24 f500 family">￥{{ goodsDetail.pay.wechat_price }}</view>
					</view>
					<view class="place_list flex">
						<view class="place_txt s24 familythree f400">商品总额：</view>
						<view class="place_dy_txt s24 f500 family">￥{{ goodsDetail.pay.total_amount }}</view>
					</view>
					<view class="place_list flex">
						<view class="place_txt s24 familythree f400">成交金额：</view>
						<view class="place_dy_txt s24 f500 family" style="color: #000">￥{{ goodsDetail.order_price || '' }}</view>
					</view>
					<view v-if="goodsDetail.pay.is_prepay == 1" class="place_list flex">
						<view class="place_txt s24 familythree f400">定金支付：</view>
						<view class="place_dy_txt s24 f500 family" style="color: #000000">
							￥{{ goodsDetail.deposit }}
							<text style="color: red" v-if="goodsDetail.state == 1 && goodsDetail.paymenttime == null" class="place_dy_txt s24 f500 family">(未付)</text>
							<text style="color: green" v-if="goodsDetail.state == 1 && goodsDetail.paymenttime !== null" class="place_dy_txt s24 f500 family">(已付)</text>
							<text style="color: green" v-if="goodsDetail.state >= 2 && goodsDetail.paymenttime !== null" class="place_dy_txt s24 f500 family">(已付)</text>
						</view>
					</view>
					<view v-if="goodsDetail.pay.is_prepay == 1" class="place_list flex">
						<view class="place_txt s24 familythree f400">剩余尾款：</view>
						<!-- {{(goodsDetail.state == 1 && goodsDetail.paymenttime == null)}}定金未支付 -->
						<view class="place_dy_txt s24 f500 family" style="color: #000000">
							￥{{ goodsDetail.balance_price }}
							<text style="color: red" v-if="goodsDetail.state == 1 && goodsDetail.paymenttime !== null" class="place_dy_txt s24 f500 family">(未付)</text>
							<text style="color: red" v-if="goodsDetail.state == 1 && goodsDetail.paymenttime == null" class="place_dy_txt s24 f500 family">(未付)</text>
							<text style="color: green" v-if="goodsDetail.state >= 2 && goodsDetail.paymenttime !== null" class="place_dy_txt s24 f500 family">(已付)</text>
						</view>
					</view>
					<view class="place_list flex">
						<view class="place_txt s24 familythree f400">备注：</view>
						<view style="word-break: break-all; flex: 1" class="place_dy_txt s24 f500 family">
							{{ goodsDetail.remarks }}
						</view>
					</view>
				</view>
				<view v-if="JSON.stringify(goodsDetail.w_log) != '[]'" class="flex align-center" style="background: #fff; border-radius: 16rpx; margin: 20rpx 32rpx; padding: 20rpx 28rpx">
					<view class="flex-1 flex flex-clum align-center justify-center" :style="'padding-bottom: ' + 2 * 12 + 'rpx;'">
						<view class="flex flex-clum align-center justify-center" v-if="index != 0" v-for="(item, index) in goodsDetail.w_log" :key="index">
							<view class="" style="width: 12rpx; height: 12rpx; background: #ebbe87; border-radius: 50%"></view>
							<view class="" style="width: 4rpx; height: 77rpx; background: #ebbe87"></view>
							<view class="" v-if="index == goodsDetail.w_log.length - 1" style="width: 12rpx; height: 12rpx; background: #ebbe87; border-radius: 50%"></view>
						</view>
					</view>
					<view class="" style="margin-left: 9rpx">
						<view
							class="flex align-center justify-between"
							v-for="(item, index) in goodsDetail.w_log"
							:key="index"
							style="background: #f4f4f4; border-radius: 8rpx; width: 604rpx; height: 70rpx; margin-bottom: 20rpx"
						>
							<view
								class="flex-1"
								style="
									padding-left: 20rpx;
									font-size: 22rpx;
									color: #444444;
									display: -webkit-box;
									overflow: hidden;
									white-space: normal;
									text-overflow: ellipsis;
									word-wrap: break-word;
									-webkit-line-clamp: 1;
									-webkit-box-orient: vertical;
								"
							>
								{{ item.content }}{{ item.status_text ? '（' + item.status_text + '）' : '' }}：{{ item.user.name }}
							</view>
							<view class="" style="font-size: 22rpx; color: #444444; margin-left: 12rpx; padding-right: 20rpx">
								{{ get_dates(item.updatetime) }}
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
		<view class="bottom_box w100 flex" :style="{ height: flag == true ? '166rpx' : '98rpx' }" v-if="type">
			<view class="total_price s28 familythree f400">总计:￥{{ goodsDetail.order_price }}</view>
		</view>
	</view>
</template>

<script>
import djs from './daojishi.vue';
export default {
	components: {
		djs
	},
	data() {
		return {
			title: '',
			state: '',
			image: '../static/left_jian.png',
			color: 'black',
			showGoodsNav: false, //是否显示订单状态
			flag: null,
			goodsData: {},
			goodsDetail: {},
			type: false, //是否可以提交订单
			imgType: false, //是否显示状态左侧图
			state1: null
		};
	},
	onLoad(options) {
		this.goodsData = JSON.parse(options.data);
		this.state1 = options.state;
		this.flag = this.bottomNav();
		if (this.state1 == 0) {
			this.getOrderInfo();
		} else {
			this.getManageInfo();
		}
	},
	methods: {
		getOrderInfo() {
			const that = this;
			uni.showLoading({
				title: '加载中'
			});
			this.$request({
				url: 'order/getOrderInfo',
				data: {
					id: this.goodsData.id
				}
			}).then((res) => {
				if (res.data.code == 1) {
					that.goodsDetail = res.data.data;
					that.goodsDetail.refundstatus = that.goodsData.refundstatus;
					that.goodsDetail.refund = that.goodsData.refund;
					that.goodsDetail.is_prepay = that.goodsData.is_prepay;
					that.goodsDetail.wedding = that.goodsData.wedding;
					const item = that.goodsDetail;
					//物流发货
					if (item.send_type == 0) {
						if (item.is_prepay) {
							//定金支付
							// 正常状态
							if (item.refundstatus == 0 && item.refund.length == 0) {
								if (item.state == 1) {
									if (item.paymenttime) {
										that.state = '余款未结';
									} else {
										that.state = '等待付款';
									}
								} else if (item.state == 2) {
									if (item.wedding?.u_type == 1) {
										that.state = '待发货';
									} else {
										that.state = '待确认';
									}
								} else if (item.state == 3) {
									that.state = '待收货';
								} else if (item.state == 4) {
									that.state = '已签收';
								} else if (item.state == 6) {
									that.state = '已完成';
								} else if (item.state == 7) {
									that.state = '已取消';
								}
							}
							// 支付取消订单
							if (item.refundstatus != 0) {
								if (item.refundstatus == 1) {
									that.state = '申请中';
								} else if (item.refundstatus == 2) {
									that.state = '取消订单已通过';
								} else if (item.refundstatus == 3) {
									that.state = '取消订单未通过';
								}
							}
							// 申请退货订单
							if (item.refund.length != 0 && item.refund.opre_type == 0) {
								if (item.refund.state == 0) {
									that.state = '申请退货中';
								} else if (item.refund.state == 2) {
									that.state = '申请退货未通过';
								} else if (item.refund.state == 1 && item.refund.refund_state == 0) {
									that.state = '申请退货已通过';
								} else if (item.refund.state == 6 && item.refund.refund_state == 0 && !(item.refund.return_sure > 0)) {
									that.state = '等待商家收货';
								} else if (item.refund.return_sure > 0 && item.refund.state == 6) {
									that.state = '退款中';
								} else if (item.refund.state == 4) {
									that.state = '退款成功';
								}
							}
							// 申请换货订单
							if (item.refund.length != 0 && item.refund.opre_type == 1) {
								if (item.refund.state == 0) {
									that.state = '申请换货中';
								} else if (item.refund.state == 2) {
									that.state = '申请换货未通过';
								} else if (item.refund.state == 1 && item.refund.refund_state == 0) {
									that.state = '申请换货已通过';
								} else if (item.refund.state == 6 && item.refund.refund_state == 0 && !(item.refund.return_sure > 0)) {
									that.state = '等待商家收货';
								} else if (item.refund.return_sure > 0 && item.refund.state == 6 && item.refund.refund_state != 2) {
									that.state = '备货中';
								} else if (item.refund.state != 4 && item.refund.refund_state == 2) {
									that.state = '待收货';
								} else if (item.refund.state == 4) {
									that.state = '已完成';
								}
							}
							// 申请维修订单
							if (item.refund.length != 0 && item.refund.opre_type == 2) {
								if (item.refund.state == 0) {
									that.state = '申请维修中';
								} else if (item.refund.state == 2) {
									that.state = '申请维修未通过';
								} else if (item.refund.state == 1 && item.refund.refund_state == 0) {
									that.state = '申请维修已通过';
								} else if (item.refund.state == 6 && item.refund.refund_state == 0 && !(item.refund.return_sure > 0)) {
									that.state = '等待商家收货';
								} else if (item.refund.return_sure > 0 && item.refund.state == 6 && item.refund.refund_state != 2) {
									that.state = '维修中';
								} else if (item.refund.state != 4 && item.refund.refund_state == 2) {
									that.state = '待收货';
								} else if (item.refund.state == 4) {
									that.state = '已完成';
								}
							}
						} else {
							//全款支付
							// 正常状态
							if (item.refundstatus == 0 && item.refund.length == 0) {
								if (item.state == 1) {
									that.state = '待支付';
								} else if (item.state == 2) {
									if (item.wedding?.u_type == 1) {
										that.state = '待发货';
									} else {
										that.state = '待确认';
									}
								} else if (item.state == 3) {
									that.state = '待收货';
								} else if (item.state == 4) {
									that.state = '已签收';
								} else if (item.state == 6) {
									that.state = '已完成';
								} else if (item.state == 7) {
									that.state = '已取消';
								}
							}
							// 支付取消订单
							if (item.refundstatus != 0) {
								if (item.refundstatus == 1) {
									that.state = '申请中';
								} else if (item.refundstatus == 2) {
									that.state = '取消订单已通过';
								} else if (item.refundstatus == 3) {
									that.state = '取消订单未通过';
								}
							}
							// 申请退货订单
							if (item.refund.length != 0 && item.refund.opre_type == 0) {
								if (item.refund.state == 0) {
									that.state = '申请退货中';
								} else if (item.refund.state == 2) {
									that.state = '申请退货未通过';
								} else if (item.refund.state == 1 && item.refund.refund_state == 0) {
									that.state = '申请退货已通过';
								} else if (item.refund.state == 6 && item.refund.refund_state == 0 && !(item.refund.return_sure > 0)) {
									that.state = '等待商家收货';
								} else if (item.refund.return_sure > 0 && item.refund.state == 6) {
									that.state = '退款中';
								} else if (item.refund.state == 4) {
									that.state = '退款成功';
								}
							}
							// 申请换货订单
							if (item.refund.length != 0 && item.refund.opre_type == 1) {
								if (item.refund.state == 0) {
									that.state = '申请换货中';
								} else if (item.refund.state == 2) {
									that.state = '申请换货未通过';
								} else if (item.refund.state == 1 && item.refund.refund_state == 0) {
									that.state = '申请换货已通过';
								} else if (item.refund.state == 6 && item.refund.refund_state == 0 && !(item.refund.return_sure > 0)) {
									that.state = '等待商家收货';
								} else if (item.refund.return_sure > 0 && item.refund.state == 6 && item.refund.refund_state != 2) {
									that.state = '备货中';
								} else if (item.refund.state != 4 && item.refund.refund_state == 2) {
									that.state = '待收货';
								} else if (item.refund.state == 4) {
									that.state = '已完成';
								}
							}
							// 申请维修订单
							if (item.refund.length != 0 && item.refund.opre_type == 2) {
								if (item.refund.state == 0) {
									that.state = '申请维修中';
								} else if (item.refund.state == 2) {
									that.state = '申请维修未通过';
								} else if (item.refund.state == 1 && item.refund.refund_state == 0) {
									that.state = '申请维修已通过';
								} else if (item.refund.state == 6 && item.refund.refund_state == 0 && !(item.refund.return_sure > 0)) {
									that.state = '等待商家收货';
								} else if (item.refund.return_sure > 0 && item.refund.state == 6 && item.refund.refund_state != 2) {
									that.state = '维修中';
								} else if (item.refund.state != 4 && item.refund.refund_state == 2) {
									that.state = '待收货';
								} else if (item.refund.state == 4) {
									that.state = '已完成';
								}
							}
						}
					} else if (item.send_type == 1) {
						//商家配送
						if (item.is_prepay) {
							//定金支付
							// 正常状态
							if (item.refundstatus == 0 && item.refund.length == 0) {
								if (item.state == 1) {
									if (item.paymenttime) {
										that.state = '余款未结';
									} else {
										that.state = '等待付款';
									}
								} else if (item.state == 2) {
									that.state = '待配送';
								} else if (item.state == 3) {
									that.state = '配送中';
								} else if (item.state == 4) {
									that.state = '已签收';
								} else if (item.state == 6) {
									that.state = '已完成';
								} else if (item.state == 7) {
									that.state = '已取消';
								}
							}
							// 支付取消订单
							if (item.refundstatus != 0) {
								if (item.refundstatus == 1) {
									that.state = '申请中';
								} else if (item.refundstatus == 2) {
									that.state = '取消订单已通过';
								} else if (item.refundstatus == 3) {
									that.state = '取消订单未通过';
								}
							}
							// 申请退货订单
							if (item.refund.length != 0 && item.refund.opre_type == 0) {
								if (item.refund.state == 0) {
									that.state = '申请退货中';
								} else if (item.refund.state == 2) {
									that.state = '申请退货未通过';
								} else if (item.refund.state == 1 && item.refund.refund_state == 0) {
									that.state = '申请退货已通过';
								} else if (item.refund.state == 6 && item.refund.refund_state == 0 && !(item.refund.return_sure > 0)) {
									that.state = '等待商家收货';
								} else if (item.refund.return_sure > 0 && item.refund.state == 6) {
									that.state = '退款中';
								} else if (item.refund.state == 4) {
									that.state = '退款成功';
								}
							}
							// 申请换货订单
							if (item.refund.length != 0 && item.refund.opre_type == 1) {
								if (item.refund.state == 0) {
									that.state = '申请换货中';
								} else if (item.refund.state == 2) {
									that.state = '申请换货未通过';
								} else if (item.refund.state == 1 && item.refund.refund_state == 0) {
									that.state = '申请换货已通过';
								} else if (item.refund.state == 6 && item.refund.refund_state == 0 && !(item.refund.return_sure > 0)) {
									that.state = '等待商家收货';
								} else if (item.refund.return_sure > 0 && item.refund.state == 6 && item.refund.refund_state != 2) {
									that.state = '备货中';
								} else if (item.refund.state != 4 && item.refund.refund_state == 2) {
									that.state = '正在送货';
								} else if (item.refund.state == 4) {
									that.state = '已完成';
								}
							}
							// 申请维修订单
							if (item.refund.length != 0 && item.refund.opre_type == 2) {
								if (item.refund.state == 0) {
									that.state = '申请维修中';
								} else if (item.refund.state == 2) {
									that.state = '申请维修未通过';
								} else if (item.refund.state == 1 && item.refund.refund_state == 0) {
									that.state = '申请维修已通过';
								} else if (item.refund.state == 6 && item.refund.refund_state == 0 && !(item.refund.return_sure > 0)) {
									that.state = '等待商家收货';
								} else if (item.refund.return_sure > 0 && item.refund.state == 6 && item.refund.refund_state != 2) {
									that.state = '维修中';
								} else if (item.refund.state != 4 && item.refund.refund_state == 2) {
									that.state = '待收货';
								} else if (item.refund.state == 4) {
									that.state = '已完成';
								}
							}
						} else {
							//全款支付
							// 正常状态
							if (item.refundstatus == 0 && item.refund.length == 0) {
								if (item.state == 1) {
									that.state = '待支付';
								} else if (item.state == 2) {
									that.state = '待配送';
								} else if (item.state == 3) {
									that.state = '配送中';
								} else if (item.state == 4) {
									that.state = '已签收';
								} else if (item.state == 6) {
									that.state = '已完成';
								} else if (item.state == 7) {
									that.state = '已取消';
								}
							}
							// 支付取消订单
							if (item.refundstatus != 0) {
								if (item.refundstatus == 1) {
									that.state = '申请中';
								} else if (item.refundstatus == 2) {
									that.state = '取消订单已通过';
								} else if (item.refundstatus == 3) {
									that.state = '取消订单未通过';
								}
							}
							// 申请退货订单
							if (item.refund.length != 0 && item.refund.opre_type == 0) {
								if (item.refund.state == 0) {
									that.state = '申请退货中';
								} else if (item.refund.state == 2) {
									that.state = '申请退货未通过';
								} else if (item.refund.state == 1 && item.refund.refund_state == 0) {
									that.state = '申请退货已通过';
								} else if (item.refund.state == 6 && item.refund.refund_state == 0 && !(item.refund.return_sure > 0)) {
									that.state = '等待商家收货';
								} else if (item.refund.return_sure > 0 && item.refund.state == 6) {
									that.state = '退款中';
								} else if (item.refund.state == 4) {
									that.state = '退款成功';
								}
							}
							// 申请换货订单
							if (item.refund.length != 0 && item.refund.opre_type == 1) {
								if (item.refund.state == 0) {
									that.state = '申请换货中';
								} else if (item.refund.state == 2) {
									that.state = '申请换货未通过';
								} else if (item.refund.state == 1 && item.refund.refund_state == 0) {
									that.state = '申请换货已通过';
								} else if (item.refund.state == 6 && item.refund.refund_state == 0 && !(item.refund.return_sure > 0)) {
									that.state = '等待商家收货';
								} else if (item.refund.return_sure > 0 && item.refund.state == 6 && item.refund.refund_state != 2) {
									that.state = '备货中';
								} else if (item.refund.state != 4 && item.refund.refund_state == 2) {
									that.state = '正在送货';
								} else if (item.refund.state == 4) {
									that.state = '已完成';
								}
							}
							// 申请维修订单
							if (item.refund.length != 0 && item.refund.opre_type == 2) {
								if (item.refund.state == 0) {
									that.state = '申请维修中';
								} else if (item.refund.state == 2) {
									that.state = '申请维修未通过';
								} else if (item.refund.state == 1 && item.refund.refund_state == 0) {
									that.state = '申请维修已通过';
								} else if (item.refund.state == 6 && item.refund.refund_state == 0 && !(item.refund.return_sure > 0)) {
									that.state = '等待商家收货';
								} else if (item.refund.return_sure > 0 && item.refund.state == 6 && item.refund.refund_state != 2) {
									that.state = '维修中';
								} else if (item.refund.state != 4 && item.refund.refund_state == 2) {
									that.state = '待收货';
								} else if (item.refund.state == 4) {
									that.state = '已完成';
								}
							}
						}
					} else {
						//到店自提
						if (item.is_prepay) {
							//定金支付
							// 正常状态
							if (item.refundstatus == 0 && item.refund.length == 0) {
								if (item.state == 1) {
									if (item.paymenttime) {
										that.state = '余款未结';
									} else {
										that.state = '等待付款';
									}
								} else if (item.state == 2) {
									if (item.wedding?.u_type == 1) {
										that.state = '待取货';
									} else {
										that.state = '待确认';
									}
								} else if (item.state == 3) {
									that.state = '待取货';
								} else if (item.state == 4) {
									that.state = '已签收';
								} else if (item.state == 6) {
									that.state = '已完成';
								} else if (item.state == 7) {
									that.state = '已取消';
								}
							}
							// 支付取消订单
							if (item.refundstatus != 0) {
								if (item.refundstatus == 1) {
									that.state = '申请中';
								} else if (item.refundstatus == 2) {
									that.state = '取消订单已通过';
								} else if (item.refundstatus == 3) {
									that.state = '取消订单未通过';
								}
							}
							// 申请退货订单
							if (item.refund.length != 0 && item.refund.opre_type == 0) {
								if (item.refund.state == 0) {
									that.state = '申请退货中';
								} else if (item.refund.state == 2) {
									that.state = '申请退货未通过';
								} else if (item.refund.state == 1 && item.refund.refund_state == 0) {
									that.state = '申请退货已通过';
								} else if (item.refund.state == 6 && item.refund.refund_state == 0 && !(item.refund.return_sure > 0)) {
									that.state = '等待商家收货';
								} else if (item.refund.return_sure > 0 && item.refund.state == 6) {
									that.state = '退款中';
								} else if (item.refund.state == 4) {
									that.state = '退款成功';
								}
							}
							// 申请换货订单
							if (item.refund.length != 0 && item.refund.opre_type == 1) {
								if (item.refund.state == 0) {
									that.state = '申请换货中';
								} else if (item.refund.state == 2) {
									that.state = '申请换货未通过';
								} else if (item.refund.state == 1 && item.refund.refund_state == 0) {
									that.state = '申请换货已通过';
								} else if (item.refund.state == 6 && item.refund.refund_state == 0 && !(item.refund.return_sure > 0)) {
									that.state = '等待商家收货';
								} else if (item.refund.return_sure > 0 && item.refund.state == 6 && item.refund.refund_state != 2) {
									that.state = '备货中';
								} else if (item.refund.state != 4 && item.refund.refund_state == 2) {
									that.state = '已交货';
								} else if (item.refund.state == 4) {
									that.state = '已完成';
								}
							}
							// 申请维修订单
							if (item.refund.length != 0 && item.refund.opre_type == 2) {
								if (item.refund.state == 0) {
									that.state = '申请维修中';
								} else if (item.refund.state == 2) {
									that.state = '申请维修未通过';
								} else if (item.refund.state == 1 && item.refund.refund_state == 0) {
									that.state = '申请维修已通过';
								} else if (item.refund.state == 6 && item.refund.refund_state == 0 && !(item.refund.return_sure > 0)) {
									that.state = '等待商家收货';
								} else if (item.refund.return_sure > 0 && item.refund.state == 6 && item.refund.refund_state != 2) {
									that.state = '维修中';
								} else if (item.refund.state != 4 && item.refund.refund_state == 2) {
									that.state = '待收货';
								} else if (item.refund.state == 4) {
									that.state = '已完成';
								}
							}
						} else {
							//全款支付
							// 正常状态
							if (item.refundstatus == 0 && item.refund.length == 0) {
								if (item.state == 1) {
									that.state = '待支付';
								} else if (item.state == 2) {
									if (item.wedding?.u_type == 1) {
										that.state = '待取货';
									} else {
										that.state = '待确认';
									}
								} else if (item.state == 3) {
									that.state = '待取货';
								} else if (item.state == 4) {
									that.state = '已签收';
								} else if (item.state == 6) {
									that.state = '已完成';
								} else if (item.state == 7) {
									that.state = '已取消';
								}
							}
							// 支付取消订单
							if (item.refundstatus != 0) {
								if (item.refundstatus == 1) {
									that.state = '申请中';
								} else if (item.refundstatus == 2) {
									that.state = '取消订单已通过';
								} else if (item.refundstatus == 3) {
									that.state = '取消订单未通过';
								}
							}
							// 申请退货订单
							if (item.refund.length != 0 && item.refund.opre_type == 0) {
								if (item.refund.state == 0) {
									that.state = '申请退货中';
								} else if (item.refund.state == 2) {
									that.state = '申请退货未通过';
								} else if (item.refund.state == 1 && item.refund.refund_state == 0) {
									that.state = '申请退货已通过';
								} else if (item.refund.state == 6 && item.refund.refund_state == 0 && !(item.refund.return_sure > 0)) {
									that.state = '等待商家收货';
								} else if (item.refund.return_sure > 0 && item.refund.state == 6) {
									that.state = '退款中';
								} else if (item.refund.state == 4) {
									that.state = '退款成功';
								}
							}
							// 申请换货订单
							if (item.refund.length != 0 && item.refund.opre_type == 1) {
								if (item.refund.state == 0) {
									that.state = '申请换货中';
								} else if (item.refund.state == 2) {
									that.state = '申请换货未通过';
								} else if (item.refund.state == 1 && item.refund.refund_state == 0) {
									that.state = '申请换货已通过';
								} else if (item.refund.state == 6 && item.refund.refund_state == 0 && !(item.refund.return_sure > 0)) {
									that.state = '等待商家收货';
								} else if (item.refund.return_sure > 0 && item.refund.state == 6 && item.refund.refund_state != 2) {
									that.state = '备货中';
								} else if (item.refund.state != 4 && item.refund.refund_state == 2) {
									that.state = '已完成';
								} else if (item.refund.state == 4) {
									that.state = '已完成';
								}
							}
							// 申请维修订单
							if (item.refund.length != 0 && item.refund.opre_type == 2) {
								if (item.refund.state == 0) {
									that.state = '申请维修中';
								} else if (item.refund.state == 2) {
									that.state = '申请维修未通过';
								} else if (item.refund.state == 1 && item.refund.refund_state == 0) {
									that.state = '申请维修已通过';
								} else if (item.refund.state == 6 && item.refund.refund_state == 0 && !(item.refund.return_sure > 0)) {
									that.state = '等待商家收货';
								} else if (item.refund.return_sure > 0 && item.refund.state == 6 && item.refund.refund_state != 2) {
									that.state = '维修中';
								} else if (item.refund.state != 4 && item.refund.refund_state == 2) {
									that.state = '待收货';
								} else if (item.refund.state == 4) {
									that.state = '已完成';
								}
							}
						}
					}
					that.showGoodsNav = true;
					that.imgType = true;
					that.type = true;
				} else {
					uni.showModal({
						title: '提示',
						content: res.data.msg,
						showCancel: false,
						success: function (res) {
							if (res.confirm) {
								uni.navigateBack({});
							}
						}
					});
				}
				uni.hideLoading();
			});
		},
		getManageInfo() {
			let that = this;
			this.$request({
				url: 'manage/getOrderdetail',
				method: 'POST',
				data: {
					id: that.goodsData.id
				}
			}).then((res) => {
				if (res.data.code == 1) {
					that.goodsDetail = res.data.data;
					that.goodsDetail.wedding = this.goodsData.wedding;
					const item = that.goodsDetail;
					if (item.state == 1) {
						if (item.paymenttime) {
							that.state = '余款未结';
						} else {
							that.state = '等待付款';
						}
					} else if (item.state == 2) {
						if (item.send_type == 0) {
							if (item.wedding?.u_type == 1) {
								that.state = '待发货';
							} else {
								that.state = '待确认';
							}
						} else if (item.send_type == 1) {
							if (item.wedding?.u_type == 1) {
								that.state = '待配送';
							} else {
								that.state = '待确认';
							}
						} else if (item.send_type == 2) {
							if (item.wedding?.u_type == 1) {
								that.state = '待取货';
							} else {
								that.state = '待确认';
							}
						}
					} else if (item.state == 3) {
						that.state = '待收货';
					} else if (item.state == 4) {
						that.state = '待评价';
					} else if (item.state == 6) {
						that.state = '已完成';
					} else if (item.state == 7) {
						that.state = '已取消';
					}
					that.showGoodsNav = true;
					that.imgType = true;
					that.type = true;
				}
			});
		},
		submitOrder() {
			let that = this;
			uni.showLoading({
				title: '支付中'
			});
			uni.login({
				provider: 'weixin',
				success: function (res) {
					that
						.$request({
							url: 'pay/payment',
							method: 'POST',
							data: {
								order_id: that.goodsDetail.id,
								order_type: that.goodsDetail.order_type,
								type: 'wechat',
								method: 'miniapp',
								code: res.code
							}
						})
						.then((res) => {
							if (res.data.code == 1) {
								uni.hideLoading();
								that
									.$wx_pay(res.data.data)
									.then((res) => {
										uni.showToast({
											title: '支付成功',
											icon: 'none',
											duration: 2000
										});
										that.getOrderList();
									})
									.catch((err) => {
										uni.showToast({
											title: '取消支付',
											icon: 'none',
											duration: 2000
										});
									});
							} else {
								uni.hideLoading();
							}
						});
				}
			});
		},
		getPhone() {
			uni.makePhoneCall({
				phoneNumber: this.goodsDetail.mobile
			});
		},
		rTitle(title, skuText) {
			let text = title;
			let regex = new RegExp('####', 'g');
			text = text.replace(regex, skuText);
			return text;
		}
	}
};
</script>

<style scoped lang="scss">
.store_details {
	height: 100%;
	overflow: hidden;
	box-sizing: border-box;
	.nav_back {
		position: fixed;
		top: 0;
		width: 750upx;
		height: 318upx;
		background: linear-gradient(180deg, #ebbe87 0%, #ebbe87 100%);
		border-radius: 0upx 0upx 24upx 24upx;
	}
	.scroll-Y {
		height: 100%;
		overflow-y: auto;
	}
	.content {
		position: relative;
		height: calc(100% - 318rpx);
	}
	.dingdan_wanc_box {
		position: relative;
		margin-bottom: 64upx;

		.wc_left_image {
			width: 64upx;
			height: 64upx;
			margin-left: 198upx;
		}

		.wc_right_txt {
			font-size: 44upx;
			color: #ffffff;
			margin-left: 24upx;
		}
	}

	.edit_box {
		width: 662upx;
		height: 124upx;
		background: #ffffff;
		border-radius: 16upx 16upx 16upx 16upx;
		margin: 42upx auto;
		margin-bottom: 0;
		padding-right: 20upx;
		overflow: hidden;

		.top_wz_name {
			margin-top: 20upx;
			margin-left: 20upx;

			.weizhi_img {
				width: 44upx;
				height: 44upx;
			}

			.wz_name_phone {
				color: #000000;
				margin-top: 4upx;
			}

			.edit_txt {
				color: #666666;
				margin-top: 4upx;
				margin-right: 10upx;
			}

			.right_jt {
				width: 10upx;
				height: 20upx;
				margin-top: -2upx;
			}
		}

		.dizhi_txt {
			margin-top: 10upx;
			margin-left: 26upx;
			color: #999999;
		}
	}

	.payment_box {
		position: relative;
		margin-top: 50upx;
		padding-bottom: 40rpx;

		.payment_txt {
			color: rgba(255, 255, 255, 0.8);
		}

		.payment_money {
			color: #ffffff;
		}

		.surplus_txt {
			color: rgba(255, 255, 255, 0.8);
		}
	}

	.goods_box {
		width: 666upx;
		background: #ffffff;
		border-radius: 16upx 16upx 16upx 16upx;
		margin: 42upx auto;
		padding-left: 20upx;
		overflow: hidden;
		padding-bottom: 20upx;
		margin-bottom: 0;

		.sotre_name_box {
			margin-top: 20upx;
		}

		.right_jian {
			width: 48upx;
			height: 48upx;
			margin-top: -6upx;
		}
	}

	.goods_details {
		margin-top: 20upx;

		.goods_image {
			width: 162upx;
			height: 162upx;
			border-radius: 8upx 8upx 8upx 8upx;
		}

		.goods_name_status {
			margin-left: 20upx;

			.goods_name {
				width: 400upx;
				height: 36upx;
				color: #666666;
				overflow: hidden;
				text-overflow: ellipsis;
				white-space: nowrap;
			}

			.yixuan_bod {
				color: #999999;
				margin-top: 12upx;
			}

			.money_num_box {
				margin-top: 38upx;

				.money_name {
					color: #e4493a;
				}

				.huax_money {
					font-family: Source Han Sans CN-Regular, Source Han Sans CN;
					color: #999999;
					margin-top: 12upx;
					text-decoration: line-through;
					margin-left: 10upx;
				}

				.goods_num {
					color: #000000;
					margin-top: 10rpx;
				}
			}
		}
	}

	.gift_box {
		width: 646upx;
		background: #f4f5f9;
		border-radius: 16upx 16upx 16upx 16upx;
		margin-top: 34upx;
		padding-bottom: 16upx;
		overflow: hidden;

		.gift_list {
			margin-top: 16upx;
			margin-left: 20upx;
			padding-right: 20upx;

			.gift_left_txt {
				width: 520upx;
				overflow: hidden;
				text-overflow: ellipsis;
				white-space: nowrap;
				color: #888888;
			}
		}
	}

	.place_order_box {
		width: 646upx;
		background: #fff;
		border-radius: 16upx 16upx 16upx 16upx;
		margin: 20upx auto;
		padding-left: 20upx;
		padding-right: 20upx;
		padding-bottom: 20upx;
		overflow: hidden;

		.place_list {
			margin-top: 20upx;

			.place_txt {
				width: 120upx;
				color: #888;
				text-align: justify;
				text-align-last: justify;
			}

			.place_dy_txt {
				flex: 1;
				color: #000;
				margin-left: 20upx;
			}

			.phone_txt {
				color: #e4b77f;
			}
		}
	}

	.bottom_box {
		height: 98upx;
		background: #ffffff;
		box-shadow: 0upx -1upx 0upx 2upx rgba(0, 0, 0, 0.1);
		position: fixed;
		bottom: 0;

		.total_price {
			color: #000000;
			line-height: 98upx;
			margin-left: 520upx;
		}

		.submit_btn {
			width: 240upx;
			height: 80upx;
			background: #ebbe87;
			border-radius: 40upx 40upx 40upx 40upx;
			line-height: 80upx;
			color: #ffffff;
			margin-top: 10upx;
			margin-left: 40upx;
		}
	}
}
</style>
<style>
page {
	height: 100%;
	background-color: #f4f5f9;
}

.flex {
	display: flex;
}

.flex-1 {
	flex: 1;
}

.flex-clum {
	flex-direction: column;
}

.align-center {
	align-items: center;
}

.justify-around {
	justify-content: space-evenly;
}

.justify-center {
	justify-content: center;
}

.justify-between {
	justify-content: space-between;
}

.justify-end {
	justify-content: end;
}

.bold {
}

.pre-pay {
	text-align: center;
	font-weight: bold;
	color: #fff;
}
</style>
